import request from '@/utils/request'

// 查询采购计划列表
export function listPurchasePlan(query) {
    return request({
        url: '/purchasePlan/list',
        method: 'get',
        params: query
    })
}

// 查询采购计划详细
export function getPurchasePlan(planNo) {
    return request({
        url: '/purchasePlan/' + planNo,
        method: 'get'
    })
}

// 查询多个采购计划
export function getPurchasePlanList(planNoList) {
    return request({
        url: '/purchasePlan/getList',
        method: 'post',
        data: planNoList
    })
}

// 新增采购计划
export function addPurchasePlan(data) {
    return request({
        url: '/purchasePlan',
        method: 'post',
        data: data
    })
}

// 修改采购计划
export function updatePurchasePlan(data) {
    return request({
        url: '/purchasePlan',
        method: 'put',
        data: data
    })
}

// 删除采购计划
export function delPurchasePlan(planNo) {
    return request({
        url: '/purchasePlan/' + planNo,
        method: 'delete'
    })
}

// 查询统计数据
export function getStatisticInfo(cycleNo) {
    return request({
        url: '/purchasePlan/getStatistics',
        method: 'post',
        data: cycleNo
    })
}

// 查询最新采购计划列表
export function listLatestPurchasePlan(query) {
    return request({
        url: '/purchasePlan/latest/list',
        method: 'get',
        params: query,
    })
}

// 判断是否有了最新的采购计划
export function checkLatestPurchasePlan() {
    return request({
        url: '/purchasePlan/check/isForecast',
        method: 'get',
    })
}

// 确认算法预测出的采购计划
export function confirmPurchasePlan(data) {
    return request({
        url: '/purchasePlan/confirm',
        method: 'post',
        data: data
    })
}

//查询最新的采购计划编号用于插入新的采购计划
export function getLatestPlanNo() {
    return request({
        url: '/purchasePlan/final/planNo',
        method: 'get',
    })
}

//需求预测
export function planDemandForecast(cycleNo){
    return request({
        url: '/purchasePlan/demand/forecast',
        method: 'post',
        data: cycleNo
    })
}